package Homework722;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

public class DouDiZhu {
	public static void main(String[] args) {
		//准备牌
		int count=0;
		HashMap<Integer,String> map=new HashMap<>();
		ArrayList<Integer> poker=new ArrayList<>();
		String[] colors={"♠","♣","♦","♥"};
		String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
		for(int i=0;i<54;i++){
			poker.add(i);
		}
		map.put(count++, "大王");
		map.put(count++, "小王");
		for(String number:numbers){
			for(String color:colors){
				map.put(count++, color+number);
			}
		}
		//洗牌
		Collections.shuffle(poker);

		Player p1=new Player();p1.setName("老王");
		Player p2=new Player();p2.setName("老李");
		Player p3=new Player();p3.setName("老六");
		ArrayList<Integer> dipai=new ArrayList<>();
		//摸牌
		for(int i=0;i<poker.size();i++){
			//获取每一张的牌
			int p = poker.get(i);
			if(i>=51){
				dipai.add(p);
			}else if(i%3==0){
				p1.getPoker().add(p);
			}else if(i%3==1){
				p2.getPoker().add(p);
			}else if(i%3==2){
				p3.getPoker().add(p);
			}
		}
		Collections.sort(p1.getPoker());
		Collections.sort(p2.getPoker());
		Collections.sort(p3.getPoker());
		Collections.sort(dipai);
		//看牌
		Print(p1,map);
		Print(p2,map);
		Print(p3,map);
		System.out.print("底牌:"+map.get(dipai.get(0)));
		System.out.print(","+map.get(dipai.get(1)));
		System.out.print(","+map.get(dipai.get(2)));
	}

	private static void Print(Player p, HashMap<Integer, String> map) {
		// TODO Auto-generated method stub
		ArrayList<String> arrayList = new ArrayList<>();
		System.out.print(p.getName()+"的牌：");
		for(int i=0;i<17;i++){
			arrayList.add(map.get(p.getPoker().get(i)));
		}
		System.out.println(arrayList.toString());
	}

}
